package org.nice.files;

import java.io.File;
import java.util.ArrayList;

/**
 *
 * @author katie
 */
public class NiceDir {

    public static ArrayList<String> list(String dirname) {
        if (!(dirname.charAt(dirname.length() - 1) == '/' || dirname.charAt(dirname.length() - 1) == '\\')) {
            dirname += "/";
        }
        File dir = new File(dirname);
        ArrayList<String> out = new ArrayList<String>();
        String[] children = dir.list();
        if (children == null) {
            // Either dir does not exist or is not a directory
            System.out.println("Error opening/finding directory "+dirname);
        } else {
            for (int i = 0; i < children.length; i++) {
                // Get filename of file or directory
                String filename = children[i];
                out.add(dirname+filename);
            }
        }
        return out;
    }
    

}
